function scrollHere(scroll_obj,page_obj){
	if(!scroll_obj||!page_obj){
		return;
	}
	
	var begin_top=pageScrollY(),duration=750,start_time=(new Date()).getTime(),last_top=null;
	var interval=setInterval(function() {
		var wh=window.innerHeight?window.innerHeight:document.documentElement.clientHeight;
		var dh=elementY(page_obj)+page_obj.offsetHeight;
		var ey=elementY(scroll_obj)-100;
		if(dh-ey<wh){
			ey-=(wh+ey)-dh;
		}
	if(dh<wh+100) {
		clearInterval(interval);
	}
	
	var time=(new Date()).getTime();
	var scroll=null;
	var current_top=pageScrollY();
	var p=(time-start_time)/duration;
	if(p>1) {
		scroll=ey;
		clearInterval(interval);
	}
	else {
		scroll=parseInt((ey-begin_top)*animation.ease.both(p)+begin_top);
	}
	if(last_top&&current_top!=last_top&&current_top!=0){
		clearInterval(interval);
	}
	else{
		window.scrollBy(0,scroll-current_top);last_top=scroll;
	}
},25);}

function pageScrollX() {
	return document.body.scrollLeft||document.documentElement.scrollLeft;
}

function pageScrollY() {
	return document.body.scrollTop||document.documentElement.scrollTop;	
}

function elementX(obj){
	if(ua.safari()<500&&obj.tagName=='TR') {
		obj=obj.firstChild;
	}
	var left=obj.offsetLeft;
	var op=obj.offsetParent;
	while(obj.parentNode&&document.body!=obj.parentNode) {
		obj=obj.parentNode;left-=obj.scrollLeft;
		if(op==obj){
			if(ua.safari()<500&&obj.tagName=='TR'){
				left+=obj.firstChild.offsetLeft;
			}
			else {
				left+=obj.offsetLeft;
			}
			op=obj.offsetParent;
		}
	}
	return left;
}
		
function elementY(obj){
	if(ua.safari()<500&&obj.tagName=='TR'){
		obj=obj.firstChild;
	}
	var top=obj.offsetTop;var op=obj.offsetParent;
	while(obj.parentNode&&document.body!=obj.parentNode){
		obj=obj.parentNode;
		top-=obj.scrollTop;
		if(op==obj){
			if(ua.safari()<500&&obj.tagName=='TR'){
				top+=obj.firstChild.offsetTop;
			}
			else {
				top+=obj.offsetTop;
			}
			op=obj.offsetParent;
		}
	}
	return top;
}

var ua={
	ie:function(){
		return this._ie;
	},
	firefox:function(){
		return this._firefox;
	},
	opera:function(){
		return this._opera;
	},
	safari:function(){
		return this._safari;
	},
	windows:function(){
		return this._windows;
	},
	osx:function(){
		return this._osx;
	},
	populate:function(){
		var agent=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso).(\d+\.\d+))|(?:Opera.(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))/.exec(navigator.userAgent);var os=/(Mac OS X;)|(Windows;)/.exec(navigator.userAgent);
			if(agent){
				ua._ie=agent[1]?parseFloat(agent[1]):NaN;ua._firefox=agent[2]?parseFloat(agent[2]):NaN;ua._opera=agent[3]?parseFloat(agent[3]):NaN;ua._safari=agent[4]?parseFloat(agent[4]):NaN;
			}
			else{
				ua._ie=ua._firefox=ua._opera=ua._safari=NaN;
			}
	
			if(os){
				ua._osx=!!os[1];
				ua._windows=!!os[2];
			}
		else{
			ua._osx=ua._windows=false;
		}
	},
	adjustBehaviors:function(){
		onloadRegister(addSafariLabelSupport);
		if(ua.ie()<7){
			try {
				document.execCommand('BackgroundImageCache',false,true);
			}
			catch(ignored){}
		}
	}
};
